﻿<UserControl x:Class="Topics.Radical.Presentation.Validation.ValidationSampleView"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      mc:Ignorable="d" 
      d:DesignHeight="393" d:DesignWidth="529"
      xmlns:markup="http://schemas.topics.it/wpf/radical/windows/markup">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="70*" />
            <RowDefinition Height="30*" />
        </Grid.RowDefinitions>

        <TextBox Text="{markup:EditorBinding Path=Text}" Grid.Row="0" Margin="33,47,220,0" Height="25" VerticalAlignment="Top" />

        <ListBox Grid.Row="1" Grid.IsSharedSizeScope="True" ItemsSource="{Binding Path=ValidationErrors}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition SharedSizeGroup="displayNameColumn" Width="Auto" />
                            <ColumnDefinition SharedSizeGroup="errorsColumn" Width="*" />
                        </Grid.ColumnDefinitions>

                        <StackPanel Orientation="Horizontal" Grid.Column="0" Margin="0,0,5,0" >
                            <TextBlock Text="{Binding Path=KeyDisplayName}" Margin="0,0,5,0" Foreground="Red" />
                            <TextBlock Text="(" Margin="0" Foreground="Red" />
                            <TextBlock Text="{Binding Path=Key}" Margin="0" Grid.Column="1" Foreground="Red" />
                            <TextBlock Text=")" Margin="0,0,5,0" Foreground="Red" />
                        </StackPanel>
                        <TextBlock Text="{Binding}" Grid.Column="2" Foreground="Brown" />

                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <TextBlock Text="This is validated while writing" HorizontalAlignment="Left" Margin="33,26,0,0" VerticalAlignment="Top"/>
        <Button Content="Click to run full validation" 
                HorizontalAlignment="Left" 
                Command="{markup:AutoCommandBinding Path=RunValidation}"
                Margin="33,77,0,0" VerticalAlignment="Top" MinWidth="75"/>
        <CheckBox Content="Merge errors" IsChecked="{Binding Path=MergeErrors}" HorizontalAlignment="Left" Margin="33,102,0,0" VerticalAlignment="Top"/>

    </Grid>
</UserControl>
